class Cat(name: String, color: String) {
  var age: Int = 0

  def this(name: String, color: String, age: Int) = {
    this(name, color)
    this.age = age
  }

  def this(name: String) = {
    this(name, "黄色")
  }

  def eat() {
    println("name=" + name + " color=" + color + ",age=" + age + "  正在吃吃吃")
  }
  override def toString: String = {
    "name=" + name + " color=" + color + ",age=" + age
  }

}

object Cat {
  def apply(name: String, color: String): Cat = {
    new Cat(name, color)
  }
  def apply(name: String): Cat = {
    new Cat(name)
  }
  def main(args: Array[String]) {
    var cat = new Cat("小花", "白色")
    cat.age = 1
    cat.eat()
    cat = new Cat("小黑", "黑色", 2)
    cat.eat()
    cat = new Cat("小黄")
    cat.age = 3
    cat.eat()
    val c = Cat("小花2", "白色2")
    c.eat()
    println("c="+c)
    val c2 = Cat("小丽")
    c2.eat()
    println("c="+c2)
  }
}